<?php

namespace app\index\controller;

/**
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/09/05
 * Time: 16:13
 */
class Api extends Base
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getWsPrice()
    {
        $params = input();
        if (!isset($params['regionid'])) {
            return json(['code' => 0, 'msg' => '缺少regionid', 'data' => []]);
        }
        if (!isset($params['number'])) {
            return json(['code' => 0, 'msg' => '缺少number', 'data' => []]);
        }
        $maps = [];
        $maps[] = ['regionid', '=', $params['regionid']];
        $maps[] = ['number', '=', $params['number']];
        $ws_detail = model('work_station')->get_detail($maps, 'id,price');
        if (empty($ws_detail)) {
            return json(['code' => 0, 'msg' => '找不到对应工位/办公室', 'data' => []]);
        }

        $data['price'] = $ws_detail['price'];
        return json(['code' => 1, 'msg' => 'OK', 'data' => $data]);
    }
}
